"""
 Created by 饼干 on 2019/10/29
"""
from flask import Flask
from flask_login import LoginManager
from flask_mail import Mail

from app.models.base import db

__author__ = '饼干'

login_manager = LoginManager()
mail = Mail()


def create_app():
    app = Flask(__name__, static_url_path='/fisher/static')
    app.config.from_object('app.secure')
    app.config.from_object('app.setting')
    register_blueprint(app)
    login_manager.init_app(app)
    login_manager.login_view = 'web.login'
    login_manager.login_message = '请先登录或注册'

    mail.init_app(app)

    db.init_app(app)
    db.create_all(app=app)
    return app


def register_blueprint(app):
    from app.web.book import web
    app.register_blueprint(web, url_prefix='/fisher')


